package m.jclecai.com.adapter;

import android.content.Context;
import android.support.v7.widget.RecyclerView;
import android.view.View;
import android.view.ViewGroup;

import com.alibaba.fastjson.JSONArray;

import java.util.List;

import m.jclecai.com.R;
import m.jclecai.com.adapter.holder.RecomfamousHolder;
import m.jclecai.com.bean.reconmend.ReconmentContent;
import m.jclecai.com.listener.Callback;

/**
 * Created by ZD on 2017/7/19.
 */

public class RecomfamousAdapter extends RecyclerView.Adapter<RecomfamousHolder> {

    private Context mContext;
    private Callback mCallback;
    private JSONArray mArray;
    private List<ReconmentContent> records;

    public RecomfamousAdapter(Context mContext,JSONArray array) {
        this.mContext = mContext;
        this.mArray = array;
    }
    public RecomfamousAdapter(Context mContext,List<ReconmentContent> records) {
        this.mContext = mContext;
        this.records = records;
    }

    @Override
    public RecomfamousHolder onCreateViewHolder(ViewGroup parent, int viewType) {
        return new RecomfamousHolder(View.inflate(mContext, R.layout.item_recom_famous,null));
    }

    @Override
    public void onBindViewHolder(RecomfamousHolder holder, int position) {
        holder.initData(mCallback,records.get(position));
    }

    @Override
    public int getItemCount() {
        return this.records.size();
    }

    public void setmCallback(Callback mCallback) {
        this.mCallback = mCallback;
    }
}
